<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2024/12/9
  Time: 18:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>Title</title>
    <style>
        .bookCover{
            width: 50px;
            height: 50px;
        }
    </style>
</head>
<body>

<form action="/22library2/book/updateBook" method="POST" enctype="multipart/form-data">
    <input type="hidden" name="bookId" value="${book.bookId}">
    书名<input type="text" name="bookName" value="${book.bookName}"> <br>
    作者<input type="text" name="bookWriter" value="${book.bookWriter}"> <br>
    类型<input type="text" name="bookType" value="${book.bookType}"> <br>
    价格<input type="text" name="bookPrice" value="${book.bookPrice}"> <br>
    出版时间<input type="date" name="pubDate" value="<fmt:formatDate value="${book.pubDate}" pattern="yyyy-MM-dd"></fmt:formatDate>"> <br>
    封面<input type="file" name="mf" id="imageInput"> ${msg}
        <img src="${book.bookCover}" alt="" class="bookCover" id="bookCover">
        <br>
        <input type="submit" value="修改"></form>
</body>
<script>
    document.getElementById('imageInput').addEventListener('change', function(event) {
        let file = event.target.files[0];
        let reader = new FileReader();
        reader.onload = function(e) {
            document.getElementById('bookCover').src = e.target.result;
        };
        reader.readAsDataURL(file);
    });
</script>
</html>
